﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Helpers;
using System.Collections.ObjectModel;

namespace PrintManager
{
    public class LayoutManager : NotifyPropertyChangedBase
    {
        PrintEngine pe;

        ObservableCollection<LayoutDefinition> _layouts;
        public ObservableCollection<LayoutDefinition> Layouts
        {
            get { return _layouts; }
            set
            {
                _layouts = value;
                NotifyPropertyChanged("Layouts");
                SelectedLayout = Layouts.FirstOrDefault();
            }
        }

        LayoutDefinition _selectedLayout;
        public LayoutDefinition SelectedLayout
        {
            get { return _selectedLayout; }
            set
            {
                _selectedLayout = value;
                NotifyPropertyChanged("SelectedLayout");
                Papers = new ObservableCollection<PaperDefinition>(pe.PapersForLayout(_selectedLayout));
            }
        }

        ObservableCollection<PaperDefinition> _papers;
        public ObservableCollection<PaperDefinition> Papers
        {
            get { return _papers; }
            set
            {
                _papers = value;
                NotifyPropertyChanged("Papers");
                SelectedPaper = Papers.FirstOrDefault();
            }
        }

        PaperDefinition _selectedPaper;
        public PaperDefinition SelectedPaper
        {
            get { return _selectedPaper; }
            set
            {
                _selectedPaper = value;
                NotifyPropertyChanged("SelectedPaper");
            }
        }

        public LayoutManager( PrintEngine _pe, string module, object data )
        {
            pe = _pe;
            Layouts = new ObservableCollection<LayoutDefinition>(pe.LayoutsForReport(module, data));
        }
    }
}
